﻿package mortal.game.view.copy.groupCopy.item
{
    import Message.Game.*;
    import com.mui.controls.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.component.gconst.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;
    import mortal.game.view.common.item.*;
    import mortal.game.view.copy.groupCopy.data.*;
    import mortal.game.view.signUp.sevenDayLogin.data.*;
    import mortal.mvc.core.*;

    public class GroupCopyBossReCell extends GSprite
    {
        protected var _bg:GImageBitmap;
        protected var _getBtn:GLoadingButton;
        protected var _itemBg:GBitmap;
        protected var _boTitle:GBitmap;
        protected var _item:BaseItem;
        protected var _boNum:BitmapNumberText;
        private var _arrowSp:GSprite;
        private var _info:Object;

        public function GroupCopyBossReCell()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._bg = UIFactory.gImageBitmap(ImagesConst.ItemRoundBgOver, 0, 0, this);
            this._getBtn = UIFactory.gLoadingButton(ImagesConst.LineOffCopyCellBtn_upSkin, 24, 81, 50, 22, this);
            this._getBtn.label = "" + Language.getString(70881);
            this._itemBg = UIFactory.gBitmap(ImagesConst.petTalentSkillBg, 10, 11, this);
            this._boTitle = UIFactory.gBitmap(ImagesConst.GroupCopyTeamBoTitle, 8, -7, this);
            this._item = UIFactory.getUICompoment(BaseItem);
            this._item.setItemStyle(ItemStyleConst.Small, ImagesConst.PackItemBg, 2, 2);
            UIFactory.setObjAttri(this._item, 29, 28, -1, -1, this);
            this._boNum = UIFactory.bitmapNumberText(51, -6, "GuildWarResultAddNum.png", 13, 21, -5, this, 13, 1);
            this._boNum.text = "100";
            this._getBtn.configEventListener(MouseEvent.CLICK, this.getReward);
            this._arrowSp = UIFactory.getUICompoment(GSprite, 0, 0, this);
            var _loc_1:Number = 0.6;
            this._arrowSp.scaleY = 0.6;
            this._arrowSp.scaleX = _loc_1;
            this._arrowSp.y = 19;
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._arrowSp = null;
            SevenDayLoginUtil.removeArrow(this._getBtn);
            this._bg = null;
            this._getBtn = null;
            this._itemBg = null;
            this._boTitle = null;
            this._item = null;
            this._boNum = null;
            return;
        }// end function

        private function showGuideArrow(param1:Boolean) : void
        {
            if (param1)
            {
                SevenDayLoginUtil.genGiftArrow(this._getBtn, 0, 38, 2, this._arrowSp);
            }
            else
            {
                SevenDayLoginUtil.removeArrow(this._getBtn);
            }
            return;
        }// end function

        public function set data(param1:Object) : void
        {
            this._info = param1;
            if (this._info == null)
            {
                return;
            }
            this._boNum.text = "" + this._info.scoreMin;
            this.updateItem();
            this.updateBtn();
            return;
        }// end function

        private function updateItem() : void
        {
            var _loc_1:* = this._info.itemRewards;
            var _loc_2:* = _loc_1.split("#")[0];
            var _loc_3:* = _loc_1.split("#")[1];
            this._item.itemCode = _loc_2;
            return;
        }// end function

        private function updateBtn() : void
        {
            var _loc_1:* = int(this._info.scoreMax);
            var _loc_2:* = DefenseInfo.defenseInfo[_loc_1];
            if (_loc_2)
            {
                this._getBtn.label = "" + Language.getString(70881);
                if (_loc_2.rewards[this._info.scoreMin] == 1)
                {
                    this._item.filters = null;
                    this._getBtn.enabled = true;
                    this._getBtn.filters = null;
                    this.showGuideArrow(true);
                }
                else if (_loc_2.rewards[this._info.scoreMin] == 2)
                {
                    this._getBtn.enabled = false;
                    this._getBtn.label = "" + Language.getString(70882);
                    var _loc_3:* = [FilterConst.colorFilter2];
                    this._getBtn.filters = [FilterConst.colorFilter2];
                    this._item.filters = _loc_3;
                    this.showGuideArrow(false);
                }
                else
                {
                    this._item.filters = null;
                    this._getBtn.enabled = false;
                    this._getBtn.filters = [FilterConst.colorFilter2];
                    this.showGuideArrow(false);
                }
            }
            else
            {
                this.showGuideArrow(false);
                this._item.filters = null;
                this._getBtn.enabled = false;
                this._getBtn.filters = [FilterConst.colorFilter2];
            }
            return;
        }// end function

        private function getReward(event:MouseEvent) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.GroupCopyGetBoReward, this._info));
            return;
        }// end function

    }
}
